package com.xkstream.client.nim;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xkstream.client.entity.GamblingPartyResult;
import com.xkstream.client.nim.CustomAttachment;
import com.xkstream.client.nim.CustomAttachmentType;

import org.json.JSONObject;

import java.util.List;

/**
 * Created by admin on 2017/4/8.
 */

public class ResultAttachment extends CustomAttachment {
    List<GamblingPartyResult> list;
    int gameStatus;
    int anchorStatus;
    int gameType ;


    public ResultAttachment() {
        super(CustomAttachmentType.RESULT);
    }


    @Override
    public void parseData(String str) {
        try {
            JSONObject jsonObj = new JSONObject(str);
            gameStatus = jsonObj.getInt("game_status");
            if (jsonObj.has("returnResult")) {
                String returnResult = jsonObj.getString("returnResult");
                list = new Gson().fromJson(returnResult, new TypeToken<List<GamblingPartyResult>>() {
                }.getType());
            }
            if(jsonObj.has("anchor_status")){
                anchorStatus = jsonObj.getInt("anchor_status");
            }
            if(jsonObj.has("game_type")){
                gameType = jsonObj.getInt("game_type");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public JSONObject packData() {
        return null;
    }

    public List<GamblingPartyResult> getList() {
        return list;
    }

    public void setList(List<GamblingPartyResult> list) {
        this.list = list;
    }

    public int getGameStatus() {
        return gameStatus;
    }

    public void setGameStatus(int gameStatus) {
        this.gameStatus = gameStatus;
    }

    public int getAnchorStatus() {
        return anchorStatus;
    }

    public void setAnchorStatus(int anchorStatus) {
        this.anchorStatus = anchorStatus;
    }

    public int getGameType() {
        return gameType;
    }

    public void setGameType(int gameType) {
        this.gameType = gameType;
    }
}
